package cn.edu.fzu.homemaking.sso.domain.entity;

import cn.edu.fzu.homemaking.common.MD5Util;
import cn.edu.fzu.homemaking.sso.domain.enums.SexEnum;
import cn.edu.fzu.homemaking.sso.domain.enums.StatusEnum;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;

import java.util.Date;

@Data
public class User {

    private Long       id;

    //邮箱
    private String     email;

    //密码
    @JSONField(serialize = false)
    private String     password;

    //姓名
    private String     name;

    //性别
    private SexEnum    sex;

    //出生年月
    private Date       birth;

    //手机号码
    private String     phone;

    //家庭地址
    private String     address;

    //人脸照片
    private String     faceUrl;

    //状态
    private StatusEnum status;

    //创建时间
    private Date       createTime;

    //更新时间
    private Date       updateTime;

    public static User build(String email, String password, String name, SexEnum sex, Date birth, String phone,
                             String address, String faceUrl) {
        User user = new User();
        user.setEmail(email);
        user.setPassword(MD5Util.MD5Encode(password));
        user.setName(name);
        user.setSex(sex);
        user.setBirth(birth);
        user.setPhone(phone);
        user.setAddress(address);
        user.setFaceUrl(faceUrl);
        user.setStatus(StatusEnum.NORMAL);
        return user;
    }
}
